/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-03-22 16:42:55
 * @LastEditors: voanit
 * @LastEditTime: 2022-03-22 18:34:53
 */
import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { getChannel, ChannelActive } from '../../store/actions/channel'
// import { ChannelActive } from '../../store/actions/newsList'
export default function Channel() {
  const dispatch = useDispatch()
  const channel = useSelector((state) => {
    return state.channel
  })
  useEffect(() => {
    // dispatch(getChannel)
    dispatch(getChannel())
  }, [])
  return (
    <ul className="catagtory">
      {channel.channel.map((item) => {
        return (
          <li
            onClick={() => {
              dispatch(ChannelActive(item.id))
            }}
            key={item.id}
            className={item.id === channel.id ? 'select' : ''}
          >
            {item.name}
          </li>
        )
      })}
    </ul>
  )
}
